import { createStore, applyMiddleware } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'


import reducer from './reducer'
import logger from 'redux-logger'
import storage from 'redux-persist/lib/storage'

//对原有的 reducer 进行处理 生成 持久化的 reducer
let persistedReducer = persistReducer({ key: 'react', storage }, reducer)

//创建一个唯一的 store
let store = createStore(persistedReducer, applyMiddleware(logger))

//对唯一的 store 进行 持久化处理, 生成 持久化的 store
let persistor = persistStore(store);


export { store, persistor }